<?php @session_start(); 

	$stucode = (isset($_POST['stucode']))?$_POST['stucode']:0;
	if($stucode > 0)
	{
		include "../dbconnect.php";
		$sql = "SELECT * FROM student WHERE student_code=".$stucode;
			$result = mysql_query($sql, $link);
			mysql_query("SET NAMES UTF8");  
			$numrows = mysql_num_rows($result);
			if($numrows > 0)
			{			
				while ($arr = mysql_fetch_array($result))
				{
					//set session
					$_SESSION['student_code'] = $stucode;
					$_SESSION['student_id'] = $arr['id_student'];
					$_SESSION['student_name'] = $arr['name'];
					$_SESSION['loggon'] = 1;
					
					//$domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false;
					//setcookie("TestCookie", $arr['id_student'], time()+(3600*2), $domain, false);
				}
				echo 1;
			}
			else
			{
				echo 0;
			}
	}
	else
	{
		echo 0;
	}
?>